﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ProjectWebNhac.DAO;
using System.Data;
namespace ProjectWebNhac.BUS
{
    public class NhacSiBus
    {
        public NhacSiBus() { }
        Dataprovider dao = new Dataprovider();
        public bool ThemNhacSi(string TenNS)
        {
            return dao.XuLySuKien("sp_Admin_ThemNhacSi", CommandType.StoredProcedure,
                new object[] { "@TenNhacSi", TenNS });
        }
        public int LayMaNhacSi(string TenNS)
        {
            DataTable dt= dao.LayDuLieuThamSo("sp_Admin_LayMaNhacSiTheoTen", 
                CommandType.StoredProcedure,
                new object[] { "@TenNhacSi",TenNS });
            if (dt.Rows.Count>0)
            {
                return Convert.ToInt16(dt.Rows[0][0]);
            }
            else
            {
                ThemNhacSi(TenNS);
                return Convert.ToInt16(dao.LayDuLieuThamSo("sp_Admin_LayMaNhacSiTheoTen",
                CommandType.StoredProcedure,
                new object[] { "@TenNhacSi", TenNS }).Rows[0][0]);
            }
        }

    }
}